All Questions
40 questions
3votes
2answers
706views
Calculate the largest palindromic number from the product of two 6-digit numbers (100000 to 999999)
Are there any efficient ways to solve this problem, for example using bitwise operator? ...
6votes
3answers
370views
Leetcode - First Unique Character in a String
Given a string, find the first non-repeating character in it and return its index. If it doesn't exist, return -1. Examples: ...
3votes
1answer
2kviews
Counting subtrees where all nodes have the same value
A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value. Given the root to a binary tree, count the number of unival subtrees. For example,...
1vote
2answers
944views
String Compression
Implement a method to perform basic string compression using the counts of repeated characters. For example, the string "aabcccccaaa" would become "a2b1c5a3". If the "...
2votes
1answer
221views
Leetcode #826. Most Profit Assigning Work solution in Java (Sort + Binary Search)
Problem Statement: We have jobs: difficulty[i] is the difficulty of the ith job, and profit[i] is the profit of the ith job....
5votes
2answers
503views
Leetcode #146. LRUCache solution in Java (Doubly Linked List + HashMap)
Problem Statement Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be ...
3votes
1answer
10kviews
Solving maze problem with backtracking solution using stack
I solved the maze backtracking question using a stack however could not find any other solution like that anywhere (to validate my solution is actually a valid one). The problem statement is as ...
3votes
2answers
522views
Non repeating character in Java
Given a string s consisting of lowercase Latin Letters, find the first non repeating character in s. Input: The first line contains T denoting the number of testcases. Then follows ...
3votes
1answer
1kviews
Find all k-sum paths in a binary tree
Description: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Leetcode Code: ...
1vote
2answers
962views
Star Elements implementation in Java
Given an unsorted array. The task is to find all the star and super star elements in the array. Star are those elements which are strictly greater than all the elements on its right side. Super ...
2votes
2answers
503views
Greater on the right side in Java
Given an array of integers, replace every element with the next greatest element (greatest element on the right side) in the array. Since there is no element next to the last element, replace it ...
2votes
2answers
7kviews
Program to shorten URL and decode it back to get original URL
TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL. Design the encode and ...
6votes
2answers
2kviews
Counting ambiguous Morse Code encodings, with and without Java Streams
Unique Morse Code Words International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ...
0votes
2answers
608views
Pancake sort inteview using java
Given an array of integers arr: Write a function flip(arr, k) that reverses the order of the first k elements in the array <...
2votes
1answer
203views
Let us schedule a meeting
Description: Write a method mergeMeetings() that takes a list of multiple meeting time ranges and returns a list of condensed ranges. The integers represent the number of 30-minute blocks past 9:00am....